home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 9
/
QRZ Ham Radio Callsign Database - Volume 9.iso
/
mac
/
files
/
ant_nec
/
necprmtl.z
/
necprmtl
Wrap
Internet Message Format
|
1996-06-24
|
4KB
From dbraun@iil.intel.com Mon Nov 15 05:58:39 1993
From: dbraun@iil.intel.com (Doug Braun)
Date: Mon, 15 Nov 1993 15:41:47 +0200
To: nec-list@ee.ubc.ca
Subject: Nifty utility to use with NEC
Cc: dbraun@iil.intel.com
Content-Length: 4024
Status: RO
X-Lines: 120
One problem with NEC is that there are few ways to parameterize
any of the input data points. If you have a complex geometry and
you want to change it, you may have to re-calculate and edit a
whole binch of numbers. The geometry rotation, translation, and
reflection commands are useful, but not enough.
I wrote a little perl utility, "param". Param searchs for and
evaluates algebraic expressions in the input file, and replaces
them with their actual values. Below is the script, a sample
input file, and the results of running it through the script.
(Note that in this example, I could have used the GM command to
do essentially the same thing, but I didn't have the
documentation for the GM cpmmand at the time. By the way, I
hacked nec.f a bit sdo it wouldn't choke on blank lines, and
extra text after all the parameters on a line. This is not
required for "param" to work, though.
Sample input file:
****************************************************************************************************8
# $diplen = 0.430 # Dipole length (approx 1/2 wave)
# $sep = 0.30 # separation (diameter) of opposite dipoles 50
# $angle = 30 # tilt angle 48
# $wire = .005
# $theta = 2*3.1416/360*$angle
CE 299.7-mhz CP Lindenblad Antenna
GW 1 7 {-$sep/2} {-$diplen/2*cos($theta)} {-$diplen/2*sin($theta)} {-$sep/2} {$diplen/2*cos($theta)} {$diplen/2*sin($theta)} {$wire} Driven element
GW 2 7 {-$diplen/2*cos($theta)} {$sep/2} {-$diplen/2*sin($theta)} {$diplen/2*cos($theta)} {$sep/2} {$diplen/2*sin($theta)} {$wire} Driven element 2
GW 3 7 {$sep/2} {$diplen/2*cos($theta)} {-$diplen/2*sin($theta)} {$sep/2} {-$diplen/2*cos($theta)} {$diplen/2*sin($theta)} {$wire} Driven element 3
GW 4 7 {$diplen/2*cos($theta)} {-$sep/2} {-$diplen/2*sin($theta)} {-$diplen/2*cos($theta)} {-$sep/2} {$diplen/2*sin($theta)} {$wire} Driven element 4
GE
PT -1
EX 0 1 3 0 1.0
EX 0 2 3 0 1.0
EX 0 3 3 0 1.0
EX 0 4 3 0 1.0
RP 0 9 3 1110 90.0 0.0 -10.0 22.5
XQ
EN
****************************************************************************************************8
Output of "param", to be fed to NEC2:
****************************************************************************************************8
CE 299.7-mhz CP Lindenblad Antenna
GW 1 7 -0.15 -0.186195 -0.1075 -0.15 0.186195 0.1075 0.005 Driven element
GW 2 7 -0.186195 0.15 -0.1075 0.186195 0.15 0.1075 0.005 Driven element 2
GW 3 7 0.15 0.186195 -0.1075 0.15 -0.186195 0.1075 0.005 Driven element 3
GW 4 7 0.186195 -0.15 -0.1075 -0.186195 -0.15 0.1075 0.005 Driven element 4
GE
PT -1
EX 0 1 3 0 1.0
EX 0 2 3 0 1.0
EX 0 3 3 0 1.0
EX 0 4 3 0 1.0
RP 0 9 3 1110 90.0 0.0 -10.0 22.5
XQ
EN
****************************************************************************************************8
"Param" itself:
****************************************************************************************************8
#!/usr/local/bin/perl
$# = "%.6g"; # Set default printing format
$_definitions = "";
while(<>)
{
if(m/^#/) # look for declaration lines that start with #
{
s/^#\s*//; # remove leading whitespace
s/\s*$//; # remove trailing whitespace
eval($_);
#$_definitions = $_definitions . $_ . ";"; # append to master list
}
else
{
# Look for {} expressions
while (m/{/)
{
# Remove and print the portion of the line before the {
s/^[^{]*{//; # Remove upto and including the bracket
$_s = $&;
chop $_s;
print $_s; # Print everything except the bracket
if(m/}/)
{
s/^[^}]*}//; # Chop off everything until the }
$_expression = $&;
chop $_expression;
}
else
{
$_expression = $_;
chop $_expression;
$_ = "\n";
}
# Process the expression
#print eval($_definitions . $_expression);
print eval($_expression);
}
print; # Print the rest of the line
}
}